package com.example.administrator.encryption;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Base64;
import android.widget.TextView;

public class Base64Activity extends AppCompatActivity {
    private String datas="北国风光千里雪飘，万里冰封";
    private TextView mTextView,mTextView2;
    private String dataedit="5oiR5Lus55qE54ix77yM5aSp5Zyw5Y+v6KeB";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_base64);
        initView();

        initData();


    }

    private void initData() {
        byte[] encode = Base64.encode(datas.getBytes(), Base64.DEFAULT);

        mTextView.setText(new String(encode));

        byte[] decode = Base64.decode(dataedit, Base64.DEFAULT);
        mTextView2.setText(new String(decode));

    }

    private void initView() {
        mTextView= (TextView) findViewById(R.id.text);
        mTextView2= (TextView) findViewById(R.id.text2);
    }
}
